﻿//AcademicPlanner - course registration planning web app.
//Copyright (C) 2009  Boubacar Diallo

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


using System;
using System.Collections.Generic;
using System.Linq;
using AcademicPlanner.Data;
using AcademicPlanner.Data.Entities;
using AcademicPlanner.Data.Repositories;

namespace AcademicPlanner.Domain.Models
{
	/// <summary>
	/// Planner represents a participant in the system who executes
	/// academic planning related operations.
	/// </summary>
	/// <since>1.0</since>
    public class Planner : Actor
	{
		/// <summary>
		/// This Planner's <c>AcademicPlan</c>.
		/// </summary>
		/// <since>1.0</since>
		protected AcademicPlan plan;


		/// <summary>
		/// Gets the data layer repository for this Planner's underlying data representation.
		/// </summary>
		/// <since>1.0</since>
		protected override EntityRepository EntityRepo { get { return DomainMaster.DSAS.AccountEntityRepo; } }

		/// <summary>
		/// Gets this Planner's underlying data representation.
		/// </summary>
		/// <since>1.0</since>
		protected PlannerEntity Entity { get { return (PlannerEntity)entity; } }

		/// <summary>
		/// Gets this Planner's <c>AcademicPlan</c>.
		/// </summary>
		/// <since>1.0</since>
		public AcademicPlan Plan
		{
			get
			{
				if (plan == null)
					plan = DomainMaster.ModelsFountain.GetAcademicPlan(Entity.AcademicPlanEntity);
				return plan;
			}
		}

		
		/// <summary>
		/// Constructs a new Planner.
		/// </summary>
		/// <remarks>
		/// This constructor invokes the matching super constructor.
		/// </remarks>
		/// <since>1.0</since>
		public Planner()
			: base()
		{

		}

		/// <summary>
		/// Constructs a new Planner with the provided <c>PlannerEntity</c>.
		/// </summary>
		/// <remarks>
		/// This constructor invokes the matching super constructor.
		/// </remarks>
		/// <param name="pEntity">The Planner's <c>PlannerEntity</c>.</param>
		/// <since>1.0</since>
		public Planner(PlannerEntity pEntity)
			: base(pEntity)
		{
			
		}

		internal override void Persit()
		{
			Plan.Persit();
			base.Persit();
		}
    }
}
